//package com.daydayup.easypoi.controller;
//
//import cn.afterturn.easypoi.entity.vo.TemplateExcelConstants;
//import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
//import cn.afterturn.easypoi.view.PoiBaseView;
//import com.nengchuan.eic.team.dao.BearingConstructionMapper;
//import com.nengchuan.eic.team.model.PageQuery;
//import com.nengchuan.eic.team.model.dto.BearerConsUnitNameDTO;
//import com.nengchuan.eic.team.model.dto.BearerConstructionDTO;
//import com.nengchuan.eic.team.model.dto.BearerConstructionTotalDTO;
//import com.nengchuan.eic.team.model.vo.BearingConstructionQueryVO;
//import com.nengchuan.eic.team.service.BearingConstructionService;
//import com.nengchuan.eic.team.utils.WordUtil;
//import com.nengchuan.model.model.NcPageInfo;
//import com.nengchuan.model.model.WrappedResult;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.ui.ModelMap;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.UnsupportedEncodingException;
//import java.net.URLEncoder;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * 施工单位承载力计算<br>
// *
// * @author luo_zm
// * @create 2019/10/30 15:17
// */
//@RestController
//@RequestMapping("/de/bearing-construction")
//@Api("施工承载力")
//@Slf4j
//public class BearingConstructionController {
//
//    @Autowired
//    private BearingConstructionService bearingConstructionService;
//    @Autowired
//    private BearingConstructionMapper bearingConstructionMapper;
//
//    @ApiOperation(value = "施工单位下拉列表", notes = "施工单位下拉列表")
//    @PostMapping(value = "/getUnitNameList", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public WrappedResult<List<BearerConsUnitNameDTO>> getUnitNameList() {
//        return bearingConstructionService.getUnitNameList();
//    }
//
//    @ApiOperation(value = "施工承载力列表", notes = "施工承列表", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @PostMapping(value = "/bearingList", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public WrappedResult<NcPageInfo<BearerConstructionDTO>> bearingList(@RequestBody PageQuery<BearingConstructionQueryVO> query) {
//        return WrappedResult.success(bearingConstructionService.bearingList(query));
//    }
//
//    @ApiOperation(value = "导出施工承载力excel表格", notes = "导出施工承载力excel表格")
//    @RequestMapping(path = "/export", method = {RequestMethod.GET, RequestMethod.POST}, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
//    public void exportReport(@RequestBody PageQuery<BearingConstructionQueryVO> query, ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
//        WrappedResult<NcPageInfo<BearerConstructionDTO>> ncPageInfoWrappedResult = bearingList(query);
//        List<BearerConstructionDTO> bearerConstructionDTOList = ncPageInfoWrappedResult.getData().getData();
//        Map<String, Object> map = new HashMap<String, Object>();
//        TemplateExportParams params = new TemplateExportParams(
//                "doc/bearing.xlsx");
//        map.put("entitylist", bearerConstructionDTOList);
//        List<BearerConstructionTotalDTO> totalExport = bearingConstructionService.export(bearerConstructionDTOList);
//        map.put("total", totalExport.get(0));
//        String notes = "注: (1)“+”表示承载力可调配，“-”表示承载力可补充（或以饱和）" + "\n " +
//                "(2）对于线路工程承载力，每个班组年组搭（架设）能力约12公里。当线路工程规模较小时，应按线路工程数量配置作业班组";
//        map.put("notes", notes);
//        modelMap.put(TemplateExcelConstants.FILE_NAME, URLEncoder.encode("施工企业资源调配汇总表", "utf-8"));
//        modelMap.put(TemplateExcelConstants.PARAMS, params);
//        modelMap.put(TemplateExcelConstants.MAP_DATA, map);
//        PoiBaseView.render(modelMap, request, response,
//                TemplateExcelConstants.EASYPOI_TEMPLATE_EXCEL_VIEW);
//    }
//
//    @ApiOperation(value = "导出季度施工承载力报告", notes = "导出季度施工承载力报告")
//    @RequestMapping(path = "/exportWord", method = {RequestMethod.GET, RequestMethod.POST}, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
//    public void exportWordReport(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) {
//        Map<String, Object> map = new HashMap<String, Object>();
//        map = bearingConstructionService.getWordDataMap(map);
//        try {
//            // 2019年8月设计承载力和质量评估情况通报（9.24）
//            response.setHeader("content-type", "application/octet-stream");
//            //response.setContentType("application/octet-stream");
//            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("载力报告", "utf-8"));
//            WordUtil.exportWord("doc/bearingWord.docx", map, response.getOutputStream());
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//   /* @ApiOperation(value = "导出施工承载力报告02", notes = "导出施工承载力报告02")
//    @RequestMapping(path = "/export02", method = {RequestMethod.GET, RequestMethod.POST}, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
//    public void exportReport02(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) {
//        PageQuery<BearingConstructionQueryVO> query = new PageQuery<>();
//        query.setPageSize(60);
//        query.setPageNum(1);
//        BearingConstructionQueryVO bearingConstructionQueryVO = new BearingConstructionQueryVO();
//        query.setQueryData(bearingConstructionQueryVO);
//        WrappedResult<NcPageInfo<BearerConstructionDTO>> ncPageInfoWrappedResult = bearingList(query);
//        List<BearerConstructionDTO> bearerConstructionDTOList = ncPageInfoWrappedResult.getData().getData();
//        List<BearerConstructionTotalDTO> totalExport = bearingConstructionService.export(bearerConstructionDTOList);
//        Map<String, Object> map = new HashMap<String, Object>();
//        TemplateExportParams params = new TemplateExportParams(
//                "doc/bearing.xlsx");
//        map.put("entitylist", bearerConstructionDTOList);
//        map.put("total", totalExport.get(0));
//        map.put("totalList", totalExport);
//        String notes = "注: (1)“+”表示承载力可调配，“-”表示承载力可补充（或以饱和）" + "\n " +
//                "(2）对于线路工程承载力，每个班组年组搭（架设）能力约12公里。当线路工程规模较小时，应按线路工程数量配置作业班组";
//        map.put("notes", notes);
//        modelMap.put(TemplateExcelConstants.FILE_NAME, "施工企业资源调配汇总表");
//        modelMap.put(TemplateExcelConstants.PARAMS, params);
//        modelMap.put(TemplateExcelConstants.MAP_DATA, map);
//        PoiBaseView.render(modelMap, request, response,
//                TemplateExcelConstants.EASYPOI_TEMPLATE_EXCEL_VIEW);
//    }*/
//}
